import {
    loadingUI
} from "../../ui/layaMaxUI";
import Util from "../util/Util";
import homeUi from "./home";
import gameUi from "./game";

export default class loading extends loadingUI {

    constructor() {
        super();
        //弄个全局遮罩
    }

    onEnable() {
        var parent = this;
        window.currPage = this;
        window.currPageUtil = Util;

        Util.gameUi = gameUi;
        Util.homeUi = homeUi;

        this["背景图"].x = (Laya.stage.width - 1800) / 2;
        this["进度层"].width = Laya.stage.width;
        this["开始游戏"].x = Laya.stage.width / 2;

        this["进度层"].visible = true;
        this["开始游戏"].visible = false;

        this.updateJindu(0);
        // Laya.timer.frameLoop(1, this, this.runFun);
        Util.loadimg_home(function () {
            parent["进度层"].visible = false;
            parent["开始游戏"].visible = true;
            parent["开始游戏"].setTapCall(function () {
                parent.xiaohuiFun();
            });
            // parent.xiaohuiFun();
        }, function (e) {
            parent.updateJindu(e);
        });
    }

    updateJindu(bili) {
        this["进度值"].width = Laya.stage.width * bili;
    }

    xiaohuiFun() {
        // Laya.timer.clear(this, this.runFun);
        this.destroy(true);
        Laya.stage.addChild(new homeUi());
    }

    onDestroy(){
       
    }

}